#include "UpdatePieceNetworkEvent.h"
#include "Piece.h"

UpdatePieceNetworkEvent::UpdatePieceNetworkEvent(long id, const Position& position)
{
    message.header.code = NetworkEvent::SERVER_UPDATE_PIECE;
    message.header.sizeOfData = sizeof(message) - sizeof(message.header);
    message.data.id = id;
    message.data.x = position.x;
    message.data.y = position.y;
}

UpdatePieceNetworkEvent::UpdatePieceNetworkEvent(const Header& header, const Data& data)
{
    message.header = header;
    message.data = data;
}

UpdatePieceNetworkEvent::~UpdatePieceNetworkEvent()
{
}

void* UpdatePieceNetworkEvent::getMessageBlob()
{
    return &message;
}

size_t UpdatePieceNetworkEvent::getMessageBlobSize()
{
    return sizeof(message);
}

void UpdatePieceNetworkEvent::visitPiece(Piece* piece) const
{
    piece->handleUpdatePieceEvent(message.data.id, Position(message.data.x, message.data.y));
}
